package com.changil.nowonchangilchurch;
import android.app.Application;
import android.content.Context;
import android.util.Log;

import com.changil.nowonchangilchurch.protocol.ApiManager;
import com.changil.nowonchangilchurch.protocol.PreferenceManager;
import com.changil.nowonchangilchurch.protocol.UIPreferenceManager;
import com.nostra13.universalimageloader.cache.disc.naming.Md5FileNameGenerator;
import com.nostra13.universalimageloader.core.ImageLoader;
import com.nostra13.universalimageloader.core.ImageLoaderConfiguration;
import com.nostra13.universalimageloader.core.assist.QueueProcessingType;

public class NowonChangilChurchApp extends Application {

	private static final String LOG_TAG = NowonChangilChurchApp.class.getSimpleName();
	public static final boolean DEVELOPER_MODE = false;

	@Override
	public void onCreate() {
		if (DEVELOPER_MODE) {

		}else{

		}
		super.onCreate();
		this.init();
	}


	private void init() {
		Log.i(LOG_TAG, "init()..");
		PreferenceManager.getsInstance(this);
		UIPreferenceManager.getInstance().clearPreviewImageViewPagerPosition();
		ApiManager.getsInstance(this);
		initImageLoader(this);
	}
	
	private static void initImageLoader(Context context) {
		// This configuration tuning is custom. You can tune every option, you may tune some of them,
		// or you can create default configuration by
		//  ImageLoaderConfiguration.createDefault(this);
		// method.
		ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(context)
				.threadPriority(Thread.NORM_PRIORITY - 2)
				.denyCacheImageMultipleSizesInMemory()
				.discCacheFileNameGenerator(new Md5FileNameGenerator())
				.tasksProcessingOrder(QueueProcessingType.LIFO)
//				.writeDebugLogs() // Remove for release app
				.build();
		// Initialize ImageLoader with configuration.
		ImageLoader.getInstance().init(config);
	}
}
